# file:: character.rb
# author::  Ralph M. Churchill
# version::
# date::
#
# This source code copyright (C) 2006 by Ralph M. Churchill
# All rights reserved.
#
# Released under the terms of the GNU General Public License
# See LICENSE file for additional information.

require 'models/entity'
require 'models/container'
require 'models/logic_entity'
require 'models/command_entity'
require 'models/template_with_logic'
require 'models/describable_entity'

class CharacterTemplate < Entity
    include TemplateHasLogic
    properties :playable

    def playable?
        self.playable||=false
    end
    def create_instance
        char = Character.new
        char.template = self
        char.name = self.name.dup if self.name
        char.description = self.description.dup if self.description
        char
    end
end

class Character < Entity
    include ActsLikeLogicEntity,CanExecuteCommands,IsDescribable
    include BelongsToRoom,BelongsToRegion,HasManyItems,BelongsToAccount
    uses_templates_from CharacterDatabase 
    properties :last_command,:quiet,:verbose,:logged_in,:rank

    def initialize
        self.logged_in = false
        self.quiet = false
        self.verbose = true
        self.rank = 1
        super
    end

    def quiet?
        self.quiet
    end
    def verbose?
        self.verbose
    end
    def logged_in?
        self.logged_in
    end
    def player?
        self.account!=nil
    end
=begin
    def template
        CharacterDatabase.instance.get_template(self.template_id)
    end
=end
end
